# -*- coding:utf-8 -*-
# @File       :   login_saas.py
# @Author     :   LINING
# @Time       :   2024/7/24 15:00
# @Description : saas登录
from Core.elementOpt import Element


class LoginSaas:
    # 用户名
    _user_name = '#userName'
    # 密码
    _pwd = '#password'
    # 登录按钮
    _login_button = 'button'
    # 登录成功提示
    _login_success = "text=登录成功！"

    def __init__(self, page):
        self.page = page
        self.ele = Element(self.page)

    # 输入用户名
    def fill_user_name(self, user_name):
        self.ele.element_fill(self._user_name, user_name)

    # 输入密码
    def fill_password(self, pwd):
        self.ele.element_fill(self._pwd, pwd)

    # 点击登录
    def click_login(self):
        self.ele.element_click(self._login_button)

    # 获取登录成功元素个数
    def login_success(self):
        ele = self.ele.element_wait_for_element(self._login_success)
        return self.ele.element_count(ele)

    # 等到元素出现
    def login_success_wait(self):
        self.ele.element_wait_for_element(self._login_success)
